<?php

function xyzt_post()
{
    global $m;

    $content = $_POST['content'];
    $cuid = $_COOKIE['uid'];

    if (empty($content)) {
        msg('内容不得为空');
    }
    if (empty($cuid)) {
        msg('用户未登录');
    }

    $stmt = $m->get_stmt("INSERT INTO `w_xyzt_post` (`uid`, `time`, `content`) VALUES (?, now(), ?)");
    $stmt->bind_param('is', $cuid, $content);
    $stmt->execute();

    $err = $stmt->error;
    $stmt->close();
    if (!$err) {
        redirect('index.php?mode=xyzt&msg=' . urlencode("发表成功"));
    } else {
        msg("发表失败: " . $err);
    }
}

function get_xyzt_post()
{ 
    global $m;

    $osq = $m->query("SELECT `w_user`.`name`, `content` FROM `w_xyzt_post` left join `w_user` on `uid` = `w_user`.`id`");
    return $osq;
}
